﻿#region
using System;
using System.Deployment.Application;
using System.Net;
using System.Reflection;

#endregion

namespace AfricaDownloader
{
    public static class Utility
    {
        public static Version GetVersion()
        {
            Version version = Assembly.GetEntryAssembly().GetName().Version;
            if (ApplicationDeployment.IsNetworkDeployed)
                version = ApplicationDeployment.CurrentDeployment.CurrentVersion;
            return version;
        }

        public static string GetVersionText()
        {
            Version version = GetVersion();
            return String.Format("{0}.{1}.{2}", version.Major, version.Minor, version.Build);
        }

        public static string[] ExtractDownloadableUrls(string africaUrl)
        {
            var parameter = africaUrl.Split('?')[1];

            var downloadUrl = "http://d-c.kr/af_Movie/info.php?" + parameter;

            WebClient web = new WebClient();
            var html = web.DownloadString(downloadUrl);

            var tokens = html.Split('|');
            var urls = tokens[0].Split(',');

            return urls;
        }
    }
}